package org.kzwl.book.controller.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import org.kzwl.comm.advice.BizException;
import org.kzwl.comm.pojo.ResponseData;
import org.kzwl.comm.utils.PagingCondition;
import org.kzwl.entity.web.CuVenuesCategory;
import org.kzwl.entity.web.CuVolunteersCategory;
import org.kzwl.service.web.CuVolunteersCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张国伟/郭家恒
 * @since 2020-12-17
 */
@Api("志愿者标签")
@RestController
@RequestMapping("/cu-volunteers-category")
public class CuVolunteersCategoryController {

    @Autowired
    CuVolunteersCategoryService cuVolunteersCategoryService;

    @PostMapping("/queryList")
    public ResponseData<List<CuVolunteersCategory>> queryList()
    {
        return cuVolunteersCategoryService.queryList();
    }


    @PostMapping("/queryPage")
    public ResponseData<IPage<CuVolunteersCategory>> queryPage(@RequestBody PagingCondition pagingCondition)
    {
        return cuVolunteersCategoryService.queryPage(pagingCondition);
    }


    @PostMapping("/saveOne")
    public ResponseData<Void> saveOne(@RequestBody CuVolunteersCategory cuVenuesCategory)
    {
        if ("".equals(cuVenuesCategory.getCuVolunteersCategoryName()))
        {
            throw new BizException("标签不能为空");
        }
        return cuVolunteersCategoryService.saveOne(cuVenuesCategory);
    }

    @PostMapping("/updateOne")
    public ResponseData<Void> updateOne(@RequestBody CuVolunteersCategory cuVenuesCategory)
    {
        if ("".equals(cuVenuesCategory.getCuVolunteersCategoryName()))
        {
            throw new BizException("标签不能为空");
        }
        return cuVolunteersCategoryService.updateOne(cuVenuesCategory);
    }

    @PostMapping("/queryOne")
    public ResponseData<CuVolunteersCategory> queryOne(@RequestBody Long Id)
    {
        return cuVolunteersCategoryService.queryOne(Id);
    }


    @PostMapping("/deleteId")
    public ResponseData<Void> deleteId(@RequestBody Long Id)
    {
        return cuVolunteersCategoryService.deleteId(Id);
    }
}
